# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=sdl
pkgver=1.2.15
pkgrel=14
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard"
url="http://www.libsdl.org"
arch="all"
options="!check"  # Tests are all interactive.
license="LGPL-2.1-or-later"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
depends_dev="libx11-dev"
makedepends="$depends_dev libxext-dev libxrender-dev libice-dev
	libsm-dev libxrandr-dev mesa-dev alsa-lib-dev glu-dev tslib-dev"
source="https://www.libsdl.org/release/SDL-$pkgver.tar.gz
	SDL-1.2.10-GrabNotViewable.patch
	SDL-1.2.15-const_XData32.patch
	0001-CVE-2019-7574.patch
	0001-CVE-2019-7572.patch
	0002-CVE-2019-7572.patch
	0001-CVE-2019-7573.patch
	0001-CVE-2019-7577.patch
	0002-CVE-2019-7577.patch
	0001-CVE-2019-7575.patch
	0001-CVE-2019-7578.patch
	0001-CVE-2019-7635.patch
	0002-CVE-2019-7635.patch
	0001-CVE-2019-7636.patch
	0001-CVE-2019-7637.patch
	0002-CVE-2019-7637.patch
	0002-CVE-2019-13616.patch
	"
builddir="$srcdir"/SDL-$pkgver

sonameprefix="sdl1proper:so:"

# secfixes:
#   1.2.15-r12:
#     - CVE-2019-13616
#   1.2.15-r11:
#     - CVE-2019-7572
#     - CVE-2019-7573
#     - CVE-2019-7574
#     - CVE-2019-7575
#     - CVE-2019-7576
#     - CVE-2019-7577
#     - CVE-2019-7578
#     - CVE-2019-7635
#     - CVE-2019-7636
#     - CVE-2019-7637
#     - CVE-2019-7638

prepare() {
	update_config_sub
	default_prepare
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-nasm \
		--disable-esd \
		--disable-video-svga \
		--disable-video-ggi \
		--disable-video-aalib \
		--enable-alsa \
		--with-x \
		--disable-rpath \
		--enable-input-tslib
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

static() {
	depends=""
	pkgdesc="$pkgdesc (static libraries)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib
}

sha512sums="
ac392d916e6953b0925a7cbb0f232affea33339ef69b47a0a7898492afb9784b93138986df53d6da6d3e2ad79af1e9482df565ecca30f89428be0ae6851b1adc  SDL-1.2.15.tar.gz
20049408d4c00d895c39a7901d889d1874ebcd382e93b2e8df38bd3726e2236f4e9a980720724cf176a35d05fb0db5dbcabd42089423adeb404f2dba16d52b7b  SDL-1.2.10-GrabNotViewable.patch
c414a088350e4b039edf46b109721bea01300ad959b84c313f34d5bc085cab97107abb55a71cb8343f092546e4a36c52febf029ffa7d5bacbd580aee43c07bf3  SDL-1.2.15-const_XData32.patch
8c287d6ffcc159f19d934d560e073a716325b6a62d9dea974b92b2d4a417defc4f8441769b4761c5a2600b10a45ff401b0afbab6823880e3d54eab09e22f9859  0001-CVE-2019-7574.patch
e713d0f3d24d73831d9f116d4e15e965c5f09e19b15634e8cbf92714612b0172f24a5c542b3fde09732d17b03d7dac3aaac0d8f4e359a45c1c538970413d6e7c  0001-CVE-2019-7572.patch
3274f91e41b72cd98b6d7962013dd45289952b7af78cc7bc5fe99d4f143434243c8ef0743117d3ec6b090784dfcba8dd460679cc5b49f298ebd8b5afab78a108  0002-CVE-2019-7572.patch
3bf62a71988feff2329e298cee8ce48c636c65100959385b73953c95eea21cb069a7ed096165c252e5ef1db133330da5d095cf5ad145d9875b1197d3b5517b81  0001-CVE-2019-7573.patch
f364161069ceb5d05d329ff04f6e72d2c52baff68d0d3f2203f8a7ee3ace1efe8fc63676ea7d097ccc8eb696dcc20c6b141319ddf0c2bb6efc4fd92cb1dba038  0001-CVE-2019-7577.patch
d2f0664cc0388908ec621c84e7f889ef5abda31dc4e4d23e6e379e26475ed73863ad47b2f13d282c96ba269bdbc77e7effaf5f01032d0683ad991b506063ef19  0002-CVE-2019-7577.patch
abe54d9f29b5e6c1a91cba2bb44e0988b7ceb5a94c3f63569f436f49f282b80280cecd79ee48b9926fff458efbdf0fff019b0fdbf6530692a11a68dbec73e7ca  0001-CVE-2019-7575.patch
a31d5c685fafbca72fdc5336343b74b90b1bfd5af4b6f632b4d8271bb1a218ec6419a7994290f65e7a5fc36d921c2d3c1a25ddf0cdf29bffb7229229415eaa9f  0001-CVE-2019-7578.patch
47729b56a7d323fecd4e4cccddce06061c4f53b723cb08108e1800897da54bae0bede862a09d219dce515696d9e270d062c7aa0af1ba445cc3160cdac8e3d3f7  0001-CVE-2019-7635.patch
8e2c04d8a8167c479f56aa2b363bd3b5ee302c473642717445385210871e0c7b6bfb3020c553c4b0ca849b8a290602b20e7e398d396fdbf47980c38b0969f230  0002-CVE-2019-7635.patch
8e9fa28015e64f08d7d8124398ee5b268546105b73313490cfffdd547e67e729455535407177827e485c4132badfc48a73cce18c0ff7ff8a1c8706613acf180c  0001-CVE-2019-7636.patch
0ad1e445a067afb726df48eac55d593075c945199bd718b4116af84c15df6f5c095f541a5c8a008aef4474dda874e68517236f2f37e1539e0e5684240b058231  0001-CVE-2019-7637.patch
105378cf7609872198c83b8824a1c36463b01f5696cda6c184252b728cdd1054cdc2e68a338f5d728facd182628d2a8b29b961664e89d7f9022abc0268c9afc1  0002-CVE-2019-7637.patch
bbf11279fcf90a81b530ddfa7f84fc1b7feae8ef88f94e8095cb46818fa4617ed61669956851bca56e6799a4ea770cd1ebfa46d5d18763bf35c940643ab9fa1e  0002-CVE-2019-13616.patch
"
